<?php

namespace App\Console\Commands;

use App\Common\Utils\Helper;
use App\Models\Agent;
use App\Models\Category;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class Test extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'test {num}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '控制台做一些测试';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $num = $this->argument('num');
        $privateFun = "test{$num}";
        call_user_func([self::class, $privateFun]);
        return 1;
    }

    private function test1()
    {
        $x ="fasdgfasdf";
        echo "dasfsd";
        echo $x;
    }

    private function test2()
    {
        $x = Agent::all();
        var_dump($x);
    }

    private function test3()
    {
        $tree = Category::defaultOrder()
            ->get()
            ->toTree()
            ->toArray();
        Log::channel('daily')->info(Helper::toJson($tree));
    }

    private function test4()
    {
        $x = tap([1,2,3], function ($arr){
            $y = [];
            foreach ($arr as $k => $v){
                $y[] = $v;
            }
        });
        var_dump($x);
    }

    private function test5()
    {}

    private function test6()
    {}

    private function test7()
    {}

    private function test8()
    {}

    private function test9()
    {}

    private function test10()
    {}

    private function test11()
    {}
}
